﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;


namespace Centaline.Common
{
    [DataContract]
    [Serializable]
    public class ResultModel
    {
        public ResultModel()
        {
            Content = "Success";
            Status = 200;
            LogID = "NONE";
        }
        /// <summary>
        /// 状态代码
        /// </summary> 
        [DataMember]
        public int Status { get; set; }

        /// <summary>
        /// 状态描述
        /// </summary>
        [DataMember]
        public string StateDescription { get; set; }

        /// <summary>
        /// 数据内容
        /// </summary>
        [DataMember]
        public string Content { get; set; }

        [DataMember]
        public string Token { get; set; }

        [DataMember]
        public string LogID { get; set; }

        /// <summary>
        /// 成功、有消息输出
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static ResultModel ReturnSuccess(string content)
        {
            return new ResultModel
            {
                Content = content,
                Status = 200,
            };
        }

        /// <summary>
        /// 失败、异常，有消息输出
        /// </summary>
        /// <param name="exceptionDescription"></param>
        /// <returns></returns>
        public static ResultModel ReturnFail(string exceptionDescription)
        {
            return new ResultModel
            {
                StateDescription = exceptionDescription,
                Status = 300,
            };
        }
    }

}
